#!/usr/bin/env python
# encoding: utf-8

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from flask_cors import CORS

db = SQLAlchemy()


def create_app():
    app = Flask(__name__)
    app.config.from_pyfile('app/config/config.py')
    db.init_app(app)
    app.app_context().push()
    CORS(app, supports_credentials=True, resources=r'/*')
    from app.view import create_router
    create_router(app)
    db.create_all()
    return app
